<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Http\Requests\RegisterRequest;
use App\Models\User;

class RegisterController extends Controller
{
    public function page()
    {
        return view('auth.register', ['title' => 'Регистрация']);
    }

    public function handle(RegisterRequest $request)
    {
        $user = User::create([
            'name' => $request->get('email'),
            'email' => $request->get('email'),
            'password' => $request->get('password'),
        ]);

        auth()->login($user);

        return redirect()->route('servers.list');
    }
}
